package itcast.service.impl;

import itcast.dao.StudentDao;
import itcast.dao.impl.StudentDaoImpl;
import itcast.domain.Build;
import itcast.domain.Studnet;
import itcast.service.BuildService;
import itcast.service.StudentService;

import java.util.List;
import java.util.Map;

public class StudentServiceImpl implements StudentService {
    StudentDao studentDao = new StudentDaoImpl();

    @Override
    public Studnet findexchangeByID(String username,String name ) {
        return studentDao.finddrom_exchangeByID(username,name);
    }

    //根据学号查找学生所在宿舍
    @Override
    public List<Studnet> findDrom_manageByDate(Map<String, String[]> condition) {
        return studentDao.finddrom_exchangeByusername(condition);
    }
    //调换宿舍

    @Override
    public void updatedrom_exchange(Studnet studnet) {
        studentDao.exchange_drom(studnet);
    }

    //学生迁入信息

    @Override
    public List<Studnet> findstudent_intoAll() {
        return studentDao.findstudent_into();
    }

    //根据学号查询迁入信息

    @Override
    public Studnet findStudent_intoById(String id) {
        return studentDao.findstudent_into_ID(id);
    }
    //显示存在楼宇和宿舍

    @Override
    public List<Studnet> find_into_build_dromAll() {
        return studentDao.find_into_build_drom();
    }

    //为学生选择宿舍

    @Override
    public void update_into(Studnet studnet) {
        studentDao.update_student_into(studnet);
    }

    //查找学生管理信息

    @Override
    public List<Studnet> findAll() {
      return   studentDao.find_studentmanage();
    }
    //根据条件查找学生管理信息

    @Override
    public List<Studnet> findstudent_manageByDate(Map<String, String[]> condition) {
        return studentDao.findStudent_manageByData(condition);
    }
    //修改学生管理信息数据

    @Override
    public void updateStudent_manage(Studnet studnet) {
        studentDao.updateStudent_manage(studnet);
    }
    //根据id查找学生管理信息

    @Override
    public Studnet findstudent_manageByID(String id) {

       return studentDao.findStudnet_manageByid(Integer.parseInt(id));
    }

    //根据id删除数据
    @Override
    public void deletestudent_manage(String id) {
         studentDao.deletestudnet_managebyid(Integer.parseInt(id));
    }

    //根据id删除选中数据


    @Override
    public void delStudnet_manageSelected(String[] ids) {
        if(ids!=null &&  ids.length>0){
            //1.遍历数组
            for(String id :ids){
                //2.调用dao删除
              studentDao.deletestudnet_managebyid(Integer.parseInt(id));
            }
        }
    }

    //添加数据

    @Override
    public void addstudent_manage(Studnet studnet) {
        studentDao.addStudent_manage(studnet);
    }
    //学生登录
    @Override
    public Studnet studentdenglu(String student_username, String student_password) {
        return studentDao.studentdenglu(student_username,student_password);
    }
}

